package com.bdqn.carrental.dao;

import com.bdqn.carrental.pojo.CustomerEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface CustomerMapper {
    /**
     * 查询信息
     */
    @Select("SELECT * FROM customers")
    @ResultType(CustomerEntity.class)
    List<CustomerEntity> findAll();

    /*模糊查询*/
    @Select("<script>" +
            "SELECT * FROM customers " +
            " WHERE 1=1" +
            "<if test='phone!=null'>" +
            " and PHONE LIKE CONCAT('%',#{phone},'%')" +
            " </if>" +
           /* "LIMIT 0,10"+*/
            "</script>")
    @ResultType(CustomerEntity.class)
   List<CustomerEntity> SelectPhone(@Param("phone") String phone);
    /**
     * 下拉两边
     */
    @Select("SELECT * FROM `customers`  WHERE `MEMBERSHIP`=#{id}")
    @ResultType(CustomerEntity.class)
    List<CustomerEntity> selectHY(String id);
/**
 * 删除
 */
@Delete("DELETE FROM customers WHERE PHONE=#{phone}")
      int delCustomers(String phone);
}
